/**
 * 
 */
package com.googlecode.dynargs.model.type;

/**
 * @author Federico De Faveri defaveri@gmail.com
 *
 */
public abstract class AbstractType implements Type {
	
	protected String id;
	protected MetaType metaType;
	
	/**
	 * @param id
	 * @param metaType
	 */
	public AbstractType(String id, MetaType metaType) {
		super();
		this.id = id;
		this.metaType = metaType;
	}

	/**
	 * {@inheritDoc}
	 */
	public String getId() {
		return id;
	}

	/**
	 * {@inheritDoc}
	 */
	public MetaType getMetaType() {
		return metaType;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ObjectType other = (ObjectType) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("AbstractType [id=");
		builder.append(id);
		builder.append(", metaType=");
		builder.append(metaType);
		builder.append("]");
		return builder.toString();
	}

}
